package cn.jarlen.jwt.tools.https;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import cn.jarlen.jwt.tools.menu.IMenuProcess;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * @author jarlen
 * Create by 2024/7/18 11:38
 */
public class HttpsSample implements IMenuProcess {

    @Override
    public void onExecute(Context context) {

        ReqSample reqSample = new ReqSample();
        reqSample.setTimeout(1);
        reqSample.setConSize(10);

        ApiManager.getInstance().createSampleApi()
                .test(reqSample)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<ResSample>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(ResSample result) {
                        Toast.makeText(context, result.toString(), Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e("HttpsSample", "onError: ", e);
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
